document.write('<script src="./js/img_ver.js" type="text/javascript" charset="utf-8"></script>');

layui.use(['layer', 'form', 'element'], function () {
    window.layer = layui.layer;
    window.form = layui.form;
    window.element = layui.element;
});

var slideCaptchaDiv = '';
// 登陆前清空Session
sessionStorage.clear();

/*图形验证码获取与弹出*/
function layerVerifyCodeImg() {
    // console.log(imgBase64);
    slideCaptchaDiv = layer.open({
        id: 3,
        offset: 'auto',
        height: '200px',
        type: 1,
        title: '图形验证',
        closeBtn: 0,
        move: false,
        resize: false,

        content:
            '<div class="verBox" style="height: 260px;width: 400px;text-align:center">'
            + '<div id="imgVer" style="display:inline-block;"></div>'
            + '</div>'
        ,
        success: function () {
            $.ajax({
                url: "/check/getImgSwipe",
                data: {},
                cache: false,
                type: "GET",
                // async:false,
                success: function (data) {
                    console.log(data)
                    var SrcImage = "data:image/jpg;base64," + data.SrcImage
                    var CutImage = "data:image/jpg;base64," + data.CutImage
                    var YPosition = data.YPosition
                    var SrcImageWidth = data.SrcImageWidth;
                    var SrcImageHeight = data.SrcImageHeight;
                    //console.log(imgBase64);

                    imgVer({
                        el: '$("#imgVer")',
                        width: '320',//220
                        height: '140',//116
                        SrcImage: SrcImage,
                        CutImage: CutImage,
                        YPosition: YPosition,
                        SrcImageWidth: SrcImageWidth,
                        SrcImageHeight: SrcImageHeight,

                        success: function (captcha) {
                            //验证成功可自定义后续逻辑
                            console.log("通過了");
                            // setTimeout(function (){layer.close(slideCaptchaDiv);}, 1000);
                            layer.close(slideCaptchaDiv);
                        },
                        error: function () {
                            //alert('错误什么都不执行')
                        }
                    });

                },
                error: function () {
                    alert("error");
                }
            });


        }
    })

}